//part1:C03:ex3.36.2.cpp 
// compare two array, used of vector.
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>

int main(void)
{
    using namespace std;
    const int sz = 5;
    int i;
    vector<int> va, vb;
    srand((unsigned)time(NULL));
    for (int i = 0; i < sz; ++i)
    {
        va.push_back(rand() % 10);    
    }
    cout <<"Data had generated.Enter 5 integers between(0~9),\ncould repeated." << endl;
    int uVal;
    for (int i = 0; i < sz; ++i)
    {
        if (cin >> uVal)    
        {
            vb.push_back(uVal);
        }
    }
    cout << "Data generated is:" << endl;
    for (auto val : va)
    {
        cout << val << " ";    
    }
    cout << endl;
    cout << "your answer is:\n";
    for (auto val : vb) 
    {
        cout << val << " ";    
    }
    cout << endl;
    auto it1 = va.cbegin(), it2 = vb.cbegin();
    while (it1 != va.cend() && it2 != vb.cend())
    {
        if (*it1 != *it2)
        {
            cout << "your answer is wrong!\nTwo vector are not equal!" << endl;
            return -1;
        }
        it1++;
        it2++;
    }
    cout << "congratulation!" << endl;
    cout << endl;
    return 0;
}
